###
 # @Descripttion: 
 # @Author: duk
 # @Date: 2023-11-03 11:29:10
 # @LastEditors: Please set LastEditors
 # @LastEditTime: 2023-11-09 09:30:09
### 


#!/bin/sh
#数据库备份目录
backupdir=/opt/docker-conponse/backup/pgdata

mkdir -p  $backupdir

host=127.0.0.1
password=11271111
dbname=smartdb

# 数据库备份文件名称，以时间作为唯一码
TIMESTAMP=$(date +%Y%m%d%H%M%S)


#echo $da
#备份db_demo数据库
docker  exec smart-postgres pg_dump -p 5432 -U postgres -d smartdb  -b -v     > $backupdir/db_$TIMESTAMP.sql  
echo  ${TIMESTAMP} success!
#删除15天前的备份文件:mmin分钟、mtime天
find $backupdir -mtime +15 -name "*.sql" -exec sudo rm -rf {} \;
